<?php
/**
 * 管理后台的路由
 */

Route::namespace('Auth')->group(function () {
    Route::get('loginFailure', 'LoginController@loginFailure')->name('loginFailure');
    Route::get('noPrivilege', 'LoginController@noPrivilege')->name('noPrivilege');
    Route::post('login', 'LoginController@login');
    Route::post('register', 'RegisterController@register');
    Route::post('code', 'ResetController@sendCode');
});
Route::get('test', 'Admin\GoodInfoController@test');
Route::middleware('admin.privilege.check')->group(function () {
//    Route::post('test', function (\Illuminate\Http\Request $request) {
//        return $request->all();
//    });

    // 品牌
    Route::get('brands', 'BrandController@all');
    Route::post('brand', 'BrandController@create');
    Route::patch('brand/{id}', 'BrandController@update');
    Route::delete('brand/{id}', 'BrandController@destroy');

    // 分类
    Route::get('categories', 'CategoryController@all');
    Route::post('category', 'CategoryController@create');
    Route::patch('category/{id}', 'CategoryController@update');
    Route::delete('category/{id}', 'CategoryController@destroy');

    // 分类属性
    Route::get('category/{category}/attributes', 'AttributeController@all');
    Route::post('category/{category}/attribute', 'AttributeController@create');
    Route::patch('category/{category}/attribute/{id}', 'AttributeController@update');
    Route::delete('category/{category}/attribute/{id}', 'AttributeController@destroy');

    // 商品
    Route::get('goods', 'GoodController@all');
    Route::post('good', 'GoodController@create');
    Route::patch('good/{id}', 'GoodController@update');
    Route::delete('good/{id}', 'GoodController@destroy');

    // 商品属性
    Route::get('good/{goodId}/attributes', 'GoodAttributeController@all');
    Route::post('good/{goodId}/attribute', 'GoodAttributeController@create');
    Route::patch('good/{goodId}/attribute/{id}', 'GoodAttributeController@update');
    Route::delete('good/{goodId}/attribute/{id}', 'GoodAttributeController@destroy');

    // 商品信息，包含价格，库存等
    Route::get('good/{goodId}/infos', 'GoodInfoController@all');
    Route::post('good/{goodId}/info', 'GoodInfoController@create');
    Route::patch('good/{goodId}/info/{id}', 'GoodInfoController@update');
    Route::delete('good/{goodId}/info/{id}', 'GoodInfoController@destroy');
});
